/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.db;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "clearing_posdetail")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PosDetail.findAll", query = "SELECT p FROM PosDetail p"),
    @NamedQuery(name = "PosDetail.findById", query = "SELECT p FROM PosDetail p WHERE p.id = :id"),
    @NamedQuery(name = "PosDetail.findByClearingDate", query = "SELECT p FROM PosDetail p WHERE p.clearingDate = :clearingDate"),
    @NamedQuery(name = "PosDetail.findByAccountCode", query = "SELECT p FROM PosDetail p WHERE p.accountCode = :accountCode"),
    @NamedQuery(name = "PosDetail.findByPosID", query = "SELECT p FROM PosDetail p WHERE p.posID = :posID"),
    @NamedQuery(name = "PosDetail.findByObj", query = "SELECT p FROM PosDetail p WHERE p.obj = :obj"),
    @NamedQuery(name = "PosDetail.findByMarketCode", query = "SELECT p FROM PosDetail p WHERE p.marketCode = :marketCode"),
    @NamedQuery(name = "PosDetail.findByClassCode", query = "SELECT p FROM PosDetail p WHERE p.classCode = :classCode"),
    @NamedQuery(name = "PosDetail.findByBs", query = "SELECT p FROM PosDetail p WHERE p.bs = :bs"),
    @NamedQuery(name = "PosDetail.findByQty", query = "SELECT p FROM PosDetail p WHERE p.qty = :qty"),
    @NamedQuery(name = "PosDetail.findByAvlQty", query = "SELECT p FROM PosDetail p WHERE p.avlQty = :avlQty"),
    @NamedQuery(name = "PosDetail.findByFrozeQty", query = "SELECT p FROM PosDetail p WHERE p.frozeQty = :frozeQty"),
    @NamedQuery(name = "PosDetail.findByClosePrice", query = "SELECT p FROM PosDetail p WHERE p.closePrice = :closePrice"),
    @NamedQuery(name = "PosDetail.findByCostPriceA", query = "SELECT p FROM PosDetail p WHERE p.costPriceA = :costPriceA"),
    @NamedQuery(name = "PosDetail.findByCostPriceB", query = "SELECT p FROM PosDetail p WHERE p.costPriceB = :costPriceB"),
    @NamedQuery(name = "PosDetail.findByOpencostprice", query = "SELECT p FROM PosDetail p WHERE p.opencostprice = :opencostprice"),
    @NamedQuery(name = "PosDetail.findByAvgCostPrice", query = "SELECT p FROM PosDetail p WHERE p.avgCostPrice = :avgCostPrice"),
    @NamedQuery(name = "PosDetail.findByHedgeFlag", query = "SELECT p FROM PosDetail p WHERE p.hedgeFlag = :hedgeFlag"),
    @NamedQuery(name = "PosDetail.findByPosType", query = "SELECT p FROM PosDetail p WHERE p.posType = :posType"),
    @NamedQuery(name = "PosDetail.findByPutCall", query = "SELECT p FROM PosDetail p WHERE p.putCall = :putCall"),
    @NamedQuery(name = "PosDetail.findByCurrency", query = "SELECT p FROM PosDetail p WHERE p.currency = :currency"),
    @NamedQuery(name = "PosDetail.findByPl", query = "SELECT p FROM PosDetail p WHERE p.pl = :pl"),
    @NamedQuery(name = "PosDetail.findByCostPL", query = "SELECT p FROM PosDetail p WHERE p.costPL = :costPL"),
    @NamedQuery(name = "PosDetail.findByTotalPL", query = "SELECT p FROM PosDetail p WHERE p.totalPL = :totalPL"),
    @NamedQuery(name = "PosDetail.findByMargin", query = "SELECT p FROM PosDetail p WHERE p.margin = :margin"),
    @NamedQuery(name = "PosDetail.findByTotalFare", query = "SELECT p FROM PosDetail p WHERE p.totalFare = :totalFare"),
    @NamedQuery(name = "PosDetail.findByInvestID", query = "SELECT p FROM PosDetail p WHERE p.investID = :investID"),
    @NamedQuery(name = "PosDetail.findByOwnUserID", query = "SELECT p FROM PosDetail p WHERE p.ownUserID = :ownUserID"),
    @NamedQuery(name = "PosDetail.findByAlterUserID", query = "SELECT p FROM PosDetail p WHERE p.alterUserID = :alterUserID"),
    @NamedQuery(name = "PosDetail.findByCreateTime", query = "SELECT p FROM PosDetail p WHERE p.createTime = :createTime"),
    @NamedQuery(name = "PosDetail.findByTimeStamp", query = "SELECT p FROM PosDetail p WHERE p.timeStamp = :timeStamp")})
public class PosDetail implements Serializable {
	public static byte[] EnCode(PosDetail msg) throws IOException {
		Codec<PosDetail> Lcode = ProtobufProxy.create(PosDetail.class);
		return Lcode.encode(msg);
	}
	public static PosDetail DeCode(byte[] data) throws IOException {
	Codec<PosDetail> Lcode = ProtobufProxy.create(PosDetail.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private Integer id;
    @Basic(optional = false)
    @Column(name = "ClearingDate")
    @Temporal(TemporalType.DATE)
    private Date clearingDate;
	@Protobuf
	private long clearingDateL;
    @Basic(optional = false)
    @Column(name = "AccountCode")
    @Protobuf
	private String accountCode;
    @Column(name = "PosID")
    @Protobuf
	private String posID;
    @Basic(optional = false)
    @Column(name = "Obj")
    @Protobuf
	private String obj;
    @Basic(optional = false)
    @Column(name = "MarketCode")
    @Protobuf
	private String marketCode;
    @Basic(optional = false)
    @Column(name = "ClassCode")
    @Protobuf
	private String classCode;
    @Basic(optional = false)
    @Column(name = "BS")
    @Protobuf
	private String bs;
    @Basic(optional = false)
    @Column(name = "Qty")
    @Protobuf
	private int qty;
    @Basic(optional = false)
    @Column(name = "AvlQty")
    @Protobuf
	private int avlQty;
    @Column(name = "FrozeQty")
    @Protobuf
	private Integer frozeQty;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "ClosePrice")
    @Protobuf
	private Float closePrice;
    @Column(name = "CostPriceA")
    @Protobuf
	private Float costPriceA;
    @Column(name = "CostPriceB")
    @Protobuf
	private Float costPriceB;
    @Column(name = "opencostprice")
    @Protobuf
	private Float opencostprice;
    @Column(name = "AvgCostPrice")
    @Protobuf
	private Float avgCostPrice;
    @Column(name = "HedgeFlag")
    @Protobuf
	private String hedgeFlag;
    @Column(name = "PosType")
    @Protobuf
	private String posType;
    @Column(name = "PutCall")
    @Protobuf
	private String putCall;
    @Column(name = "Currency")
    @Protobuf
	private String currency;
    @Column(name = "PL")
    @Protobuf
	private Float pl;
    @Column(name = "CostPL")
    @Protobuf
	private Float costPL;
    @Column(name = "TotalPL")
    @Protobuf
	private Float totalPL;
    @Column(name = "Margin")
    @Protobuf
	private Float margin;
    @Column(name = "TotalFare")
    @Protobuf
	private Float totalFare;
    @Column(name = "InvestID")
    @Protobuf
	private String investID;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public PosDetail() {
    }

    public PosDetail(Integer id) {
        this.id = id;
    }

    public PosDetail(Integer id, Date clearingDate, String accountCode, String obj, String marketCode, String classCode, String bs, int qty, int avlQty) {
        this.id = id;
        this.clearingDate = clearingDate;
		this.clearingDateL = CodeTool.DateToLong(clearingDate);
        this.accountCode = accountCode;
        this.obj = obj;
        this.marketCode = marketCode;
        this.classCode = classCode;
        this.bs = bs;
        this.qty = qty;
        this.avlQty = avlQty;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getClearingDate() {
        return clearingDate;
    }

    public void setClearingDate(Date clearingDate) {
        this.clearingDate = clearingDate;
        this.setClearingDateL(CodeTool.DateToLong(clearingDate));
    }

    public String getAccountCode() {
        return accountCode;
    }

    public void setAccountCode(String accountCode) {
        this.accountCode = accountCode;
    }

    public String getPosID() {
        return posID;
    }

    public void setPosID(String posID) {
        this.posID = posID;
    }

    public String getObj() {
        return obj;
    }

    public void setObj(String obj) {
        this.obj = obj;
    }

    public String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        this.marketCode = marketCode;
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public String getBs() {
        return bs;
    }

    public void setBs(String bs) {
        this.bs = bs;
    }

    public int getQty() {
        return qty;
    }

    public void setQty(int qty) {
        this.qty = qty;
    }

    public int getAvlQty() {
        return avlQty;
    }

    public void setAvlQty(int avlQty) {
        this.avlQty = avlQty;
    }

    public Integer getFrozeQty() {
        return frozeQty;
    }

    public void setFrozeQty(Integer frozeQty) {
        this.frozeQty = frozeQty;
    }

    public Float getClosePrice() {
        return closePrice;
    }

    public void setClosePrice(Float closePrice) {
        this.closePrice = closePrice;
    }

    public Float getCostPriceA() {
        return costPriceA;
    }

    public void setCostPriceA(Float costPriceA) {
        this.costPriceA = costPriceA;
    }

    public Float getCostPriceB() {
        return costPriceB;
    }

    public void setCostPriceB(Float costPriceB) {
        this.costPriceB = costPriceB;
    }

    public Float getOpencostprice() {
        return opencostprice;
    }

    public void setOpencostprice(Float opencostprice) {
        this.opencostprice = opencostprice;
    }

    public Float getAvgCostPrice() {
        return avgCostPrice;
    }

    public void setAvgCostPrice(Float avgCostPrice) {
        this.avgCostPrice = avgCostPrice;
    }

    public String getHedgeFlag() {
        return hedgeFlag;
    }

    public void setHedgeFlag(String hedgeFlag) {
        this.hedgeFlag = hedgeFlag;
    }

    public String getPosType() {
        return posType;
    }

    public void setPosType(String posType) {
        this.posType = posType;
    }

    public String getPutCall() {
        return putCall;
    }

    public void setPutCall(String putCall) {
        this.putCall = putCall;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public Float getPl() {
        return pl;
    }

    public void setPl(Float pl) {
        this.pl = pl;
    }

    public Float getCostPL() {
        return costPL;
    }

    public void setCostPL(Float costPL) {
        this.costPL = costPL;
    }

    public Float getTotalPL() {
        return totalPL;
    }

    public void setTotalPL(Float totalPL) {
        this.totalPL = totalPL;
    }

    public Float getMargin() {
        return margin;
    }

    public void setMargin(Float margin) {
        this.margin = margin;
    }

    public Float getTotalFare() {
        return totalFare;
    }

    public void setTotalFare(Float totalFare) {
        this.totalFare = totalFare;
    }

    public String getInvestID() {
        return investID;
    }

    public void setInvestID(String investID) {
        this.investID = investID;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PosDetail)) {
            return false;
        }
        PosDetail other = (PosDetail) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.db.PosDetail[ id=" + id + " ]";
    }

    public long getClearingDateL() {
        return clearingDateL;
    }

    public void setClearingDateL(long clearingDateL) {
        this.clearingDateL = clearingDateL;
		this.clearingDate = CodeTool.LongToDate(clearingDateL);
    }
    
}
